<?php namespace Home\Controller;
use \Hdphp\Controller\Controller;
/*
 * 公共部分的控制器
 * 
 * */
 	class CommonController extends Controller
 	{
 		public function __construct()
		{
			parent::__construct();
			/*
			 * 头部
			 * */	
			$topdata = Db::table("category")
				  ->where("pid",0)
				  ->limit(3)
				  ->get();
			//p($data);die;
			View::with("topdata",$topdata);
			
			/*
			 * 右侧
			 * */
			 //右侧分类
			$rightcategory = Db::table("category")->get();
			
			foreach($rightcategory as $k=>$v){
				$rightcategory[$k]['count'] = Db::table("article")->where("category_cid",$v['cid'])->count(); 
			}
			//p($rightcategory);die;
			View::with("rightcategory",$rightcategory);
			//右侧标签
			$righttag = Db::table("tag")->get();
			View::with("righttag",$righttag);
			
			/*
			 * 底部公共区域
			 * */
			$footerNewdata = Db::table("article")
						   ->where("is_recycle",0)
						   ->limit(2)
						   ->orderBy("sendtime","desc")
						   ->field("aid","title","sendtime")
						   ->get();
			//p($footerNewdata);die;
			View::with("footerNewdata",$footerNewdata);
			//标签云
			$footerttag = Db::table("tag")->get();
			View::with("footerttag",$footerttag);
			//友情链接
			$footerlink = Db::table("link")->limit(3)->get();
			View::with("footerlink",$footerlink);
			//底部网站配置
			$websetdata = Db::table("webset")->get();
			//p($websetdata);die;
			View::with("websetdata",$websetdata);
		}
 		
		

 	}
